//
//  EGWebViewController.m
//  Orchard
//
//  Created by 黄勇锋 on 16/8/19.
//  Copyright © 2016年 itcast. All rights reserved.
//

#import "EGWebViewController.h"


@interface EGWebViewController()

@property (strong,nonatomic) UIWebView *webView;

@end


@implementation EGWebViewController

- (void)viewDidLoad{
    
    [super viewDidLoad];
    
    self.automaticallyAdjustsScrollViewInsets = NO;
    
    [self setupUI];
    
    [self presentWebContent];
    
}

- (void)setModel:(EGHomeModel *)model{
    
    _model = model;
}


- (void)setupUI{
    
   //添加控件
    [self.view addSubview:self.webView];
    
   //设置约束
    [self.webView makeConstraints:^(MASConstraintMaker *make) {
        
        make.edges.equalTo(UIEdgeInsetsMake(64, 0, 0, 0));
    }];
}


#pragma mark - 显示网页内容
- (void)presentWebContent{
    
    NSURL *url = [NSURL URLWithString:self.model.customURL];
    
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    
    [self.webView loadRequest:request];
}


- (UIWebView *)webView{
    
    if (_webView == nil) {
        
        _webView = [[UIWebView alloc]init];
        _webView.backgroundColor = [UIColor greenColor];
    }
    return _webView;
}





@end
